package Lee_code;

import java.util.*;

public class Lee_151 {
    public String reverseWords(String s) {
        String[] in = s.split(" ");
        List<String> list = new ArrayList<>(Arrays.asList(in));

        for (String string: list)
        {
            if(string.equals(" "))
            {
                list.remove(string);
            }
        }

        Collections.reverse(list);
        return String.join(" ", list);
    }


}
